package com.qcby.demo;

import com.qcby.facory.ProxyFactory;
import com.qcby.service.UserService;
import com.qcby.service.impl.OrderServiceImpl;
import com.qcby.service.impl.UserServiceImpl;

/**
 * @author 程子强
 * @Description
 * @date 2025/7/10 9:17
 */
public class Main {
    public static void main(String[] args) {
        // 测试JDK代理
        UserService userService = new UserServiceImpl();
        UserService userServiceProxy = (UserService) ProxyFactory.createProxy(userService);

        System.out.println("测试JDK代理:");
        userServiceProxy.addUser("John Doe");

        System.out.println("jj");

        // 测试CGLIB代理
        OrderServiceImpl orderService = new OrderServiceImpl();
        OrderServiceImpl orderServiceProxy = (OrderServiceImpl) ProxyFactory.createProxy(orderService);

        System.out.println("测试CGLIB代理:");
        orderServiceProxy.createOrder("ORD-7890");
        orderServiceProxy.queryOrder("ORD-7890");
    }
}
